package com.itlong.cloud.intercept;

import com.itlong.cloud.annotation.AuthAccessRequired;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

/**
 * <desc>
 * 登录拦截器。
 * </desc>
 *
 * @createDate 2017/08/29
 */
@Aspect
@Component
public class LoginIntercept {

    private static Logger LOG = LoggerFactory.getLogger(LoginIntercept.class);

    // 定义一个切入点
    @Pointcut("execution(* com.itlong.cloud.controller..*.*(..))")
    public void excudeService() {
    }

    /**
     * <desc>
     * DEMO示例。
     * <desc/>
     *
     * @param thisJoinPoint
     * @return hello
     * @author Wenchao.L
     * @createDate 2017/08/29
     */
    @Around("excudeService() && @annotation(authAccessRequired)")
    public Object login(ProceedingJoinPoint thisJoinPoint,AuthAccessRequired authAccessRequired) throws Throwable {
        //获取拦截方法的所有属性
        MethodSignature signature = (MethodSignature) thisJoinPoint.getSignature();
        Object result = thisJoinPoint.proceed();
        //System.out.println(result);
        return result;

    }
}
